import api from '@/api'
import Notification from '@/componentsEl/notification/index.js'

const state = {
    dataList: {
        records: [],
        totalPage: 0
    },
    commodityOptions: []

};
const mutations = {
    setData(state, payload) {
        state.dataList = payload
    },
    setCommodityOptions(state, payload) {
        state.commodityOptions = payload
    }
};
const actions = {
    async get_order_model_by_status({
        commit
    }, obj) {
        const result = await api.receive.get_order_model_by_status(obj);
        if (result.code === 200) {
            commit('setData', result.data);
        }
        return result
    },
    async find_product({
        commit
    }, obj) {
        const result = await api.receive.find_product(obj);
        if (result.code === 200) {
            commit('setCommodityOptions', result.data);
        }
        return result
    },
    async receive_order({ commit }, obj) {
        const result = await api.receive.receive_order(obj);
        // if (result.code !== 200 && result.code !== 5223) {
        //   Notification.error(result.message)
        // }
        return result
    },
    async refused_order({ commit }, obj) {
        const result = await api.receive.refused_order(obj);
        // if (result.code !== 200 && result.code !== 5223) {
        //   Notification.error(result.message)
        // }
        return result
    },
    async refuse_code_tree_book_list({ commit }, obj) {
        const result = await api.order.tree_book_list(obj)
        return result
    }
};
const getters = {

};

export default {
    namespaced: true,
    state,
    actions,
    mutations,
    getters
}